package main

import (
	"fmt"
	"time"
)

func setZeroes(matrix [][]int) {
	r := len(matrix)
	c := len(matrix[0])
	location := []int{}

	// 找出0的位置
	for i := 0; i < r; i++ {
		for j := 0; j < c; j++ {
			if matrix[i][j] == 0 {
				location = append(location, i, j)
				fmt.Println(location)
			}
		}
	}

	// 给行设置为0
	fmt.Println(len(location))

	for i := 0; i < len(location); i += 2 {
		for j := 0; j < c; j++ {
			fmt.Println(location[i])
			matrix[location[i]][j] = 0
		}
	}
	// fmt.Println(matrix)

	//给列设置为0
	for i := 0; i < len(location); i += 2 {
		for j := 0; j < r; j++ {
			matrix[j][location[i+1]] = 0
		}
	}
	fmt.Println(matrix)

}

func main() {
	start := time.Now()
	matrix := [][]int{{0, 1}}
	setZeroes(matrix)
	cost := time.Since(start)
	fmt.Println(matrix)
	fmt.Println(cost)

}
